To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 20 seconds to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
     Start over!
👀 Reading hidden code
@bind zz ClickCounterWithReset("Take one step!", "Start over!")
237 ms
missing
👀 Reading hidden code
15.0 μs
ClickCounterWithReset (generic function with 3 methods)
👀 Reading hidden code
ClickCounterWithReset(text="Click", reset_text="Reset") = HTML("""
<div>
<button>$(text)</button>&nbsp;&nbsp;&nbsp;&nbsp;
<a id="reset" href="#">$(reset_text)</a>
</div>

<script id="blabla">

// Select elements relative to `currentScript`
const div = currentScript.previousElementSibling
const button = div.querySelector("button")
const reset = div.querySelector("#reset")

// we wrapped the button in a `div` to hide its default behaviour from Pluto

let count = 0

button.addEventListener("click", (e) => {
count += 1
div.value = count
div.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
})

reset.addEventListener("click", (e) => {
count = 0
div.value = count
div.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
e.preventDefault()
})

// Set the initial value
div.value = count

</script>
""")
845 μs